<template>
	<view class="block-menu" v-if="data.length>0">
		<view class="menu" v-for="(item,index) in data" :key="index" :style="{width:width+'%'}"
			@click="goPage(item.href,item.title,item.id)">
			<image :src="item.image" mode=""></image>
			<text>{{item.title}}</text>
		</view>
	</view>
</template>

<script>
	import {mapState} from "vuex"
	export default {
		name: "Menu",
		props: {
			data: {
				type: [Array],
				default () {
					return []
				}
			},
			width: {
				type: Number,
				default: 20
			}
		},
		data() {
			return {

			}
		},
		computed:{
			...mapState(["userInfo"]),
		},
		methods: {
			goPage(url,title,id) {
				if(url === '/duoliang'){
					/* #ifdef H5 */
					this.$msg("请下载App体验")
					/* #endif */
					// #ifdef APP-PLUS
					var duoliangModule = uni.requireNativePlugin("duoliang-DuoLiangTaskModule");
					var params = {
					    'userId': this.userInfo.id,
					    'advertType': 0,
					    'title': '游戏中心'
					}
					duoliangModule.jumpTaskList(params);
					// #endif
					return
				}
				if (url) {
					uni.navigateTo({
						url: url+"?titleTabar="+title+"&id="+id
					})
				}
			}
		}
	}
</script>

<style scoped lang="less" src="./BlockMenu.less"></style>
